﻿Imports System.Collections
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports System.Data.OleDb

Public Class Rss
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' Get connection string from the web.config file  
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("BeachConnectionString").ConnectionString)

        ' SQL query to retrieve data from database  
        Dim SqlString As String = "SELECT * FROM [BeachesWithAverageRating] ORDER BY DateAdded DESC"

        ' Create SqlCommand object  
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text

        ' open connection and then binding data into RepeaterRSS control  
        oleDbConn.Open()
        RepeaterRSS.DataSource = cmd.ExecuteReader()
        RepeaterRSS.DataBind()
        oleDbConn.Close()

    End Sub

    Protected Function RemoveIllegalCharacters(input As Object) As String
        ' cast the input to a string  
        Dim data As String = input.ToString()
        ' replace illegal characters in XML documents with their entity references  
        data = data.Replace("&", "&amp;")
        data = data.Replace("""", "&quot;")
        data = data.Replace("'", "&apos;")
        data = data.Replace("<", "&lt;")
        data = data.Replace(">", "&gt;")
        Return data
    End Function
End Class